﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using MusicExplorer.Wrappers;
using MusicExplorer.WebRepository.Interface;
using System.Windows;

namespace MusicExplorer.Internals
{
    public class WebRepositoryAndItemToTrackListVisibilityConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var repo = values[0] as WebRepositoryWrapper;
            var item = values[1] as DetailTreeItemWrapper;

            if(repo == null) return Visibility.Collapsed;
            if ((repo.WebRepository is IGroupFilterWebRepository || repo is IArtistFilterWebRepository || repo is ILabelFilterWebRepository) && item == null) return Visibility.Collapsed;

            if (!(repo is IGroupFilterWebRepository || repo is IArtistFilterWebRepository || repo is ILabelFilterWebRepository) && item == null) return Visibility.Visible;
            if ((repo.WebRepository is IGroupFilterWebRepository || repo is IArtistFilterWebRepository || repo is ILabelFilterWebRepository) && item != null) return Visibility.Visible;
            
            return Visibility.Collapsed;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
